import {defineAsyncComponent} from "vue";

/**
 * 资源类型
 */
export type ResourceLibraryType = "image" | "video" | "file"


/**
 * 配置类型
 */
export type ConfigType = {
    name: string
    limit: number,
    component: any
}
/**
 * 类型配置
 */
const config: { [key: string]: ConfigType } = {
    image: {
        "name": "图片",
        "limit": 16,
        "component": defineAsyncComponent(() => import("./ListTemplate/ImageList.vue"))
    },
    video: {
        "name": "视频",
        "limit": 10,
        "component": defineAsyncComponent(() => import("./ListTemplate/VideoList.vue"))
    },
    file: {
        "name": "文件",
        "limit": 10,
        "component": defineAsyncComponent(() => import("./ListTemplate/FileList.vue"))
    }
}


/**
 * 获取资源分类
 */
export function getResCateType(): Array<{ label: string, value: string }> {
    let data = []
    for (let key in config) {
        data.push({label: config[key].name, value: key})
    }
    return data
}


/**
 * 获取模板组件
 * @constructor
 */
export function ComponentData() {
    let Component: { [key: string]: any } = {}
    for (let key in config) {
        Component[`${key}-list`] = config[key].component
    }
    return Component
}

export default config